package treeviews;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.image.ImageView;

public class TreeViewMainController1 implements Initializable {
	@FXML
	private TreeView<String> treeViewLeft;
	
	@FXML
	private TreeView<String> treeViewRight;

	@Override
	public void initialize(URL location, ResourceBundle resources) {
		// TODO Auto-generated method stub
		leftTreeView();
		rightTreeView();
	}
	
	@SuppressWarnings("unchecked")
	private void leftTreeView() {
		TreeItem<String> root=new TreeItem<>("Root");
		
		TreeItem<String> nodeA=new TreeItem<>("node A");
		
		TreeItem<String> nodeA1=new TreeItem<>("node A1");
		TreeItem<String> nodeA2=new TreeItem<>("node A2");
		TreeItem<String> nodeA3=new TreeItem<>("node A3");
		TreeItem<String> nodeA4=new TreeItem<>("node A4");
		nodeA.getChildren().addAll(nodeA1,nodeA2,nodeA3,nodeA4);
		
		TreeItem<String> nodeA11=new TreeItem<>("node A11",new ImageView(TreeViewMain1.getIamge("root.png")));
		TreeItem<String> nodeA12=new TreeItem<>("node A12");
		TreeItem<String> nodeA13=new TreeItem<>("node A13");
		TreeItem<String> nodeA14=new TreeItem<>("node A14");
		
		nodeA1.getChildren().addAll(nodeA11,nodeA12,nodeA13,nodeA14);
		
		TreeItem<String> nodeB=new TreeItem<>("node B");
		TreeItem<String> nodeC=new TreeItem<>("node C");
		
		
		
		root.getChildren().addAll(nodeA,nodeB,nodeC);
		treeViewLeft.setRoot(root);
		
	}
	
	@SuppressWarnings("unchecked")
	private void rightTreeView() {
		TreeItem<String> root=new TreeItem<>("Root");
		
		TreeItem<String> nodeA=new TreeItem<>("node A");
		
		TreeItem<String> nodeA1=new TreeItem<>("node A1");
		TreeItem<String> nodeA2=new TreeItem<>("node A2");
		TreeItem<String> nodeA3=new TreeItem<>("node A3");
		TreeItem<String> nodeA4=new TreeItem<>("node A4");
		nodeA.getChildren().addAll(nodeA1,nodeA2,nodeA3,nodeA4);
		
		TreeItem<String> nodeA11=new TreeItem<>("node A11",new ImageView(TreeViewMain1.getIamge("root.png")));
		TreeItem<String> nodeA12=new TreeItem<>("node A12");
		TreeItem<String> nodeA13=new TreeItem<>("node A13");
		TreeItem<String> nodeA14=new TreeItem<>("node A14");
		
		nodeA1.getChildren().addAll(nodeA11,nodeA12,nodeA13,nodeA14);
		
		TreeItem<String> nodeB=new TreeItem<>("node B");
		TreeItem<String> nodeC=new TreeItem<>("node C");
		
		
		
		root.getChildren().addAll(nodeA,nodeB,nodeC);
		treeViewRight.setRoot(root);
		
	}


}
